package com.baidu.health.Controller;

import com.baidu.health.Vo.LoginInfoVo;
import com.baidu.health.Vo.UserInfoVo;
import com.baidu.health.Vo.UserVo;
import com.baidu.health.pojo.*;
import com.baidu.health.service.*;
import com.baidu.health.utils.FileUpload;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@Api(tags = "用户中心")
public class UserController {
    @Autowired
    private TbUserService tbUserService;
    @Autowired
    private TbPlatformService platformService;
    @Autowired
    private TbIntegralVariationService tbIntegralVariationService;
    @Autowired
    private TbJurisdictionService jurisdictionService;
    @Autowired
    private TbMerchantAudditService tbMerchantAudditService;
    //用户使用用户名和密码登录
    @ApiOperation("账号密码登录")
    @PostMapping("/loginusername")
    public ResultResponse loginusername(@RequestBody LoginInfoVo loginInfoVo){
        return tbUserService.selectloginusername(loginInfoVo);
    }
    //查询登录人的基本数据
    @ApiOperation("userinfo")
    @PostMapping("/getUserInfo")
    public ResultResponse getUserInfo(@RequestBody UserInfoVo userInfoVo){
        return tbUserService.getUserInfo(userInfoVo);
    }
    //无需返回
    @ApiOperation("模拟接口")
    @PostMapping("/loginOut")
    public ResultResponse loginOut(){
        return tbUserService.loginOut();
    }
    //用户使用手机号和验证码登录
    @ApiOperation("用手机号和验证码登录")
    @PostMapping("/logionuserphone")
    public ResultResponse logionuserphone(@RequestBody UserVo userVo){
        return tbUserService.selectlogionuserphone(userVo);
    }

    //发送验证码
    @ApiOperation("发送验证码")
    @PostMapping("/authcode/{phone}")
    public ResultResponse authcode(@PathVariable String phone){
        return   tbUserService.authcode(phone);
    }
    //积分增删表
    @ApiOperation("积分的增减")
    @PostMapping("/IntegralVariation")
    public ResultResponse IntegralVariation(@RequestBody TbIntegralVariation tbIntegralVariation){
       return tbIntegralVariationService.userVariation(tbIntegralVariation);
    }
    //积分总体的查询
    @ApiOperation("积分的查询")
    @PostMapping("/IntegralSelect/{userId}")
    public ResultResponse IntegralSelect(@PathVariable Integer userId){
       return tbIntegralVariationService.IntegralSelect(userId);
    }
    //积分删除记录
    @ApiOperation("积分的删除")
    @PostMapping("/IntegralDelete/{integralId}")
    public ResultResponse IntegralDelete(@PathVariable Integer integralId){
       return tbIntegralVariationService.IntegralDelete(integralId);
    }
    //积分的批量删除
    @ApiOperation("积分的批量删除")
    @PostMapping("/IntegralDeletes/{userId}")
    public ResultResponse IntegralDeletes(@PathVariable Integer userId){
       return tbIntegralVariationService.IntegralDeletes(userId);
    }
    //用户修改头像
    @ApiOperation("用户修改")
    @PostMapping("/updateFile")
    public String updateFile(@RequestBody MultipartFile file){
        FileUpload upload = new FileUpload();
        String imgSrc = upload.upload(file);
        return imgSrc;
    }
    //用户忘记密码
    @ApiOperation("/用户忘记密码")
    @PostMapping("/forgeTPassword")
    public ResultResponse forgeTPassword(@RequestBody UserVo userVo){
        return tbUserService.forgeTPassword(userVo);
    }
    //用户修改数据
    @ApiOperation("用户修改数据")
    @PostMapping("/updateUser")
    public ResultResponse updateUser(@RequestBody TbUser tbUser){
        return tbUserService.updateUser(tbUser);
    }
    //平台管理员登录
    @ApiOperation("平台管理员用户名登录")
    @PostMapping("/loginPlatformname")
    public ResultResponse loginPlatformname(@RequestBody TbPlatform tbPlatform){
        return platformService.loginPlatformname(tbPlatform);
    }
    //管理员使用手机号和验证码登录
    @ApiOperation("平台管理员用手机号和验证码登录")
    @PostMapping("/loginPlatformphone")
    public ResultResponse loginPlatformphone(@RequestBody TbPlatform tbPlatform){
        return platformService.loginPlatformphone(tbPlatform);
    }
    //管理员操作
    @ApiOperation("管理员进行操作")
    @PostMapping("/platformoperation/{platformId}/{jurisdictionOperation}")
    public ResultResponse platformoperation(@PathVariable Integer platformId,@PathVariable String jurisdictionOperation){
        return jurisdictionService.platformoperation(platformId,jurisdictionOperation);
    }
    //管理员查询
    @ApiOperation("管理员查询")
    @PostMapping("/platformselect")
    public ResultResponse platformselect(){
        return platformService.platformselect();
    }
    //管理员添加
    @ApiOperation("管理员添加")
    @PostMapping("/platformInsert")
    public ResultResponse platformInsert(@RequestBody TbPlatform tbPlatform){
        return platformService.platformInsert(tbPlatform);
    }
    //管理员删除
    @ApiOperation("管理员删除")
    @PostMapping("/platformDeleted/{platformId}")
    public ResultResponse platformDeleted(@PathVariable Integer platformId){
        return platformService.platformupdate(platformId);
    }
    //用户的查询
    @ApiOperation("用户查找")
    @PostMapping("/userSelect")
    public ResultResponse userSelect(){
        return tbUserService.userSelect();
    }
    //用户的修改，比如说在用户的头像/名字违规了，进行一个修改
    @ApiOperation("用户的修改")
    @PostMapping("/userUpdate/{userId}/{status}")
    public ResultResponse userUpdate(@PathVariable Integer userId,@PathVariable Integer status){
        return tbUserService.userUpdate(userId,status);
    }
    //用户修改密码
    @ApiOperation("/用户修改密码")
    @PostMapping("/userUpdatepassword")
    public ResultResponse userUpdatepassword(@RequestBody UserVo userVo){
        return tbUserService.userUpdatepassword(userVo);
    }
    //用户注册
    @ApiOperation("用户注册")
    @PostMapping("/register")
    public ResultResponse register(@RequestBody UserVo param){
        return tbUserService.register(param);
    }
    //用户注销
    @ApiOperation("用户注销")
    @PostMapping("/userDelete/{userId}")
    public ResultResponse userDelete(@PathVariable Integer userId){
        return tbUserService.deleteduserId(userId);
    }
    //客服管理的查
    @ApiOperation("/客服管理查找")
    @PostMapping("/customerSelect")
    public ResultResponse customerSelect(){
        return platformService.customerSelect();
    }
    //客服管理的增
    @ApiOperation("/客服管理增加")
    @PostMapping("/customerInsert")
    public ResultResponse customerInsert(@RequestBody TbPlatform platform){
        return platformService.customerInsert(platform);
    }
    //客服管理的删
    @ApiOperation("/客服管理删除")
    @PostMapping("/customerDelete/{platformId}")
    public ResultResponse customerDelete(@PathVariable Integer platformId){
        return platformService.customerDelete(platformId);
    }
    //客服管理的改
    @ApiOperation("/客服管理修改")
    @PostMapping("/customerUpddate")
    public ResultResponse customerUpddate(@RequestBody TbPlatform platform){
        return platformService.customerUpddate(platform);
    }
    //用户进行申请商家
    @ApiOperation("/用户进行申请商家")
    @PostMapping("/userMerchant")
    public ResultResponse userMerchant(@RequestBody TbMerchantAuddit merchantAuddit){
        return tbMerchantAudditService.userMerchant(merchantAuddit);
    }
    //用户进行申请商家
    @ApiOperation("/管理员查看用户申请商家的")
    @PostMapping("/MerchantSelect")
    public ResultResponse MerchantSelect(){
        return tbMerchantAudditService.MerchantSelect();
    }

    //管理员进行审核
    @ApiOperation("/管理员审核用户申请")
    @PostMapping("/userMerchantid/{merchantId}/{userId}/{status}")
    public ResultResponse userMerchantid(@PathVariable Integer merchantId,@PathVariable Integer userId,@PathVariable Integer status){
        return tbMerchantAudditService.userMerchantid(merchantId,userId,status);
    }
    //管理员进行吊销
    @ApiOperation("/管理员吊销")
    @PostMapping("/Merchantrevoke/{userid}")
    public ResultResponse Merchantrevoke(@PathVariable Integer userid){
        return tbMerchantAudditService.Merchantrevoke(userid);
    }
    //用户信息
    @ApiOperation("/用户信息")
    @PostMapping("/userMessage/{userid}")
    public ResultResponse userMessage(@PathVariable Integer userid){
        return tbUserService.userMessage(userid);
    }
}